<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String stupic="http://localhost:8080/stupic/";
  pageContext.setAttribute("stupic",stupic );

%>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>学员列表展示</title>
  <script src="js/jquery-3.6.0.min.js"></script>
  <script>
      $(function () {
          $("tr:first").css("background","gray");
      })
      function del(sid) {
          if (confirm("是否确定要删除")) {
              location.href="student?method=deleteStudent&sid="+sid;
          }
      }
      function gotPage() {
          var currentPage = $('[name="currentPage"]').val();
          if (currentPage<1){
              alert("页码不能小于1")
              return;
          }
          if (currentPage > ${pu.totalPage}){
              alert("页码不能超出范围")
              return;
          }
          location.href="student?method=findAllStudent&currentPage="+currentPage;


      }
  </script>
</head>
<body>
<table border="1px" width="800px" align="center">
  <caption>
    <h2>学员信息列表展示</h2>
  <a href="addstudent.html">添加新学员</a>
  <a href="product?method=findAllProduct">前往购物</a>
  </caption>
  <tr>
    <th>学号</th>
    <th>姓名</th>
    <th>性别</th>
    <th>年龄</th>
    <th>学历</th>
    <th>头像</th>
    <th>备注</th>
    <th>操作</th>
  </tr>
  <c:forEach items="${pu.list}" var="stu">
    <tr>
      <td>${stu.sid}</td>
      <td>${stu.sname}</td>
      <td>${stu.sex}</td>
      <td>${stu.age}</td>
      <td>${stu.degree}</td>
      <td>
        <img src="${stupic}${stu.pic}" width="30px" height="30px">
          </td>
      <td>${stu.mark}</td>
      <td>
        <a href="student?method=findStudentBySid&sid=${stu.sid}">详情>></a> &nbsp;&nbsp;&nbsp;
        <a href="student?method=updateToshow&sid=${stu.sid}">修改</a> &nbsp;&nbsp;&nbsp;
        <a href="javascript:void (0)" onclick="del(${stu.sid})">删除</a> &nbsp;&nbsp;&nbsp;
      </td>
    </tr>
  </c:forEach>
  <tr align="center">
    <td colspan="8">
      <span>共有${pu.totalPage}页,当前是第${pu.currentPage}页</span>&nbsp;&nbsp;&nbsp;
      <a href="student?method=findAllStudent&currentPage=1">首页</a>&nbsp;&nbsp;&nbsp;
      <a href="student?method=findAllStudent&currentPage=${pu.prePage}">上一页</a>&nbsp;&nbsp;&nbsp;
      <a href="student?method=findAllStudent&currentPage=${pu.nextPage}">下一页</a>&nbsp;&nbsp;&nbsp;
      <a href="student?method=findAllStudent&currentPage=${pu.totalPage}">末页</a>&nbsp;&nbsp;&nbsp;
      跳转到第<input type="text" name="currentPage" size="4">页
      <input type="button" value="GO" onclick="gotPage()">
    </td>

  </tr>
</table>
</body>
</html>